﻿<div class="fieldset">
    <div class="legend"><span>Date Range</span></div>
    <div class="row-fluid">
        <div class="span2">Select: </div>
        <div class="span10">
            @{
                DateTime d = System.DateTime.Now;
                int days = 0;
                switch (d.DayOfWeek.ToString())
                {
                    case "Monday":
                        days = -1;
                        break;
                    case "Tuesday":
                        days = -2;
                        break;
                    case "Wednesday":
                        days = -3;
                        break;
                    case "Thursday":
                        days = -4;
                        break;
                    case "Friday":
                        days = -5;
                        break;
                    case "Saturday":
                        days = -6;
                        break;
                }
                int daysi = 0;
                switch (d.DayOfWeek.ToString())
                {
                    case "Monday":
                        daysi = -1;
                        break;
                    case "Tuesday":
                        daysi = -2;
                        break;
                    case "Wednesday":
                        daysi = -3;
                        break;
                    case "Thursday":
                        daysi = -4;
                        break;
                    case "Friday":
                        daysi = -5;
                        break;
                    case "Saturday":
                        daysi = -6;
                        break;
                }
                daysi = (daysi - 7);
            }
            <select onchange="$('#dateRangeFrom').val(this.value.substring(0,10));$('#dateRangeTo').val(this.value.substring(11,21));" class="input-block-level">
                <option value="@(d.ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">Select option...</option>
                <option value="@(d.ToString("MM/dd/yyyy") + "-" + d.AddDays(1).ToString("MM/dd/yyyy"))">Today</option>
                <option value="@(d.AddDays(-1).ToString("MM/dd/yyyy") + "-" + d.AddDays(-1).ToString("MM/dd/yyyy"))">Yesterday</option>
                <option value="@(d.AddDays(-6).ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">Last 7 days</option>
                <option value="@(d.AddDays(days).ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">Week so far (sunday->today)</option>
                <option value="@(d.AddDays(daysi).ToString("MM/dd/yyyy") + "-" + d.AddDays(-7).ToString("MM/dd/yyyy"))">Last week so far (sunday[-7]->today[-7])</option>
                <option value="@(d.AddDays(-1 * (d.Day)).ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">Month so far</option>
                <option value="@(d.AddDays(-1 * (d.Day)).AddMonths(-1).ToString("MM/dd/yyyy") + "-" + d.AddMonths(-1).ToString("MM/dd/yyyy"))">Last month so far</option>
                <option value="@(d.AddMonths(-1).ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">1 month</option>
                <option value="@(d.AddMonths(-2).ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">2 months</option>
                <option value="@(d.AddMonths(-3).ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">3 months</option>
                <option value="@(d.AddMonths(-4).ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">4 months</option>
                <option value="@(d.AddMonths(-5).ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">5 months</option>
                <option value="@(d.AddMonths(-6).ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">6 months</option>
                <option value="@(d.AddYears(-1).ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">1 year</option>
                <option value="@(d.AddYears(-2).ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">2 years</option>
                <option value="@(d.AddYears(-3).ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">3 years</option>
                <option value="@(d.ToString("MM/dd/yyyy") + "-" + d.ToString("MM/dd/yyyy"))">Custom</option>
            </select>
        </div>
    </div>
    <div class="row-fluid">
        <div class="span2">From:</div>
        <div class="span5">
            <div id="datetimepicker2" class="input-append input-block-level">
                <input data-format="MM/dd/yyyy" type="text" name="dateFrom" id="dateRangeFrom" placeholder="From" value="@(Request["dateFrom"] ?? DateTime.Now.ToString("MM/dd/yyyy"))"style="width: 79%">
                <span class="add-on">
                    <i data-time-icon="icon-time" data-date-icon="icon-calendar" class="icon-calendar"></i>
                </span>
            </div>
        </div>
        <div class="span5">
            <div id="datetimepicker3" class="input-append input-block-level">
                <input data-format="MM/dd/yyyy" type="text" name="dateTo" id="dateRangeTo" placeholder="To" value="@(Request["dateTo"] ?? DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"))" style="width: 79%">
                <span class="add-on">
                    <i data-time-icon="icon-time" data-date-icon="icon-calendar" class="icon-calendar"></i>
                </span>
            </div>
        </div>
    </div>
</div>
